package com.wgh.search.entity;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 商品文档实体类 - 用于Elasticsearch
 */
@Data
@Document(indexName = "product_index")
public class ProductDoc {
    
    @Id
    private Long id;
    
    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    private String name;
    
    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    private String description;
    
    @Field(type = FieldType.Keyword)
    private String categoryName;
    
    @Field(type = FieldType.Keyword)
    private String brandName;
    
    @Field(type = FieldType.Integer)
    private Long categoryId;
    
    @Field(type = FieldType.Integer)
    private Long brandId;
    
    @Field(type = FieldType.Double)
    private BigDecimal price;
    
    @Field(type = FieldType.Double)
    private BigDecimal originalPrice;
    
    @Field(type = FieldType.Integer)
    private Integer sales;
    
    @Field(type = FieldType.Integer)
    private Integer stock;
    
    @Field(type = FieldType.Keyword)
    private String mainImage;
    
    @Field(type = FieldType.Boolean)
    private Boolean isHot;
    
    @Field(type = FieldType.Boolean)
    private Boolean isNew;
    
    @Field(type = FieldType.Integer)
    private Integer status;
    
    @Field(type = FieldType.Date)
    private Date createTime;
    
    @Field(type = FieldType.Date)
    private Date updateTime;
    
    @Field(type = FieldType.Nested)
    private List<SkuDoc> skus;
    
    @Field(type = FieldType.Object)
    private Map<String, String> attributes;
}